package com.xdy.mdc;

import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.xdy.mdc.activity.BaseViewModelActivity;
import com.xdy.mdc.adapter.MainAdapter;
import com.xdy.mdc.databinding.ActivityMainBinding;

import java.util.ArrayList;

/**
 * 主页面
 */
public class MainActivity extends BaseViewModelActivity<ActivityMainBinding> {

    private MainAdapter adapter;

    private static final String[] components = {
            "Divider", "TextField", "Carousel", "NavigationDrawer", "NavigationRail", "ProgressIndicators", "Snackbar", "TableLayout","TopAppbar","BottomSheet"
    };

    @Override
    protected void initViews() {
        super.initViews();
        binding.list.setHasFixedSize(true);
        binding.list.setLayoutManager(new LinearLayoutManager(this));
    }

    @Override
    protected void initDatum() {
        super.initDatum();
        adapter = new MainAdapter();
        binding.list.setAdapter(adapter);
        ArrayList<String> datum = new ArrayList<>();
        for (String component : components) {
            datum.add(component);
        }
        DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
        binding.list.addItemDecoration(dividerItemDecoration);
        adapter.setDatum(datum);
    }

    @Override
    protected void initListeners() {
        super.initListeners();
    }
}